using System;
using System.Collections.Generic;
using System.Text;

using Peradigm.Framework.Persistence;

using Liberty.Domain.CaseManagement;
using Liberty.Domain.GrantManagement;
using Liberty.Domain.ServiceMemberManagement;

using Microsoft.VisualStudio.TestTools.UnitTesting;
//using NUnit.Framework.SyntaxHelpers;

namespace Tests.DomainTests.ServiceMemberManagement
{
    [TestClass()]
    public class ServiceMemberTests : Object
    {
        #region Constants
        private const string 
            TEST_NAME           = "NUnit.Test",
            TEST_ABBREVIATION   = "NT",
            TEST_RANK_NAME      = "Sergeant Major of the Marine Corps",
            TEST_RANK_STRUCTURE = "E9",
            TEST_PAY_GRADE      = "Enlisted";

        private DateTime? TEST_DATE = DateTime.Parse( "05/05/2005" );
        #endregion

        #region Setup and Teardown ServiceMemberTests
        [TestInitialize()]
        public void SetupServiceMemberTests()
        {
        }

        [TestCleanup()]
        public void TeardownServiceMemberTests()
        {
        }
        #endregion

        #region Test Methods
        [TestMethod()]
        public void TestProperties()
        {
            ServiceMember aServiceMember = new ServiceMember();
            aServiceMember.BornOn = TEST_DATE;

            Branch aBranch = new Branch( TEST_NAME, Branch.DEFAULT_RANKING, true );
            Rank aRank = new Rank( String.Empty, Rank.DEFAULT_RANKING, true, TEST_ABBREVIATION, aBranch, TEST_PAY_GRADE, TEST_RANK_NAME, TEST_RANK_STRUCTURE );

            aRank.Abbreviation = TEST_ABBREVIATION;
            aServiceMember.Rank = aRank;

            Assert.AreEqual( aBranch.Description, aServiceMember.Branch.Description );
            Assert.AreEqual( aRank.Abbreviation, aServiceMember.Rank.Abbreviation );

            Unit aUnit = new Unit( TEST_NAME );
            aServiceMember.UnitAssignment = aUnit;
            Assert.AreEqual( aUnit.Name, aServiceMember.UnitAssignment.Name );
        }

        [TestMethod()]
        public void TestGrants()
        {
            ServiceMember serviceMember = new ServiceMember();
            CaseVolunteer volunteer = CaseVolunteer.TestInstance();

            List<Grant> grants1 = new List<Grant>();
            List<Grant> grants2 = new List<Grant>();

            grants1.Add( new Grant() );
            grants1.Add( new Grant() );

            grants2.Add( new Grant() );
            grants2.Add( new Grant() );
            grants2.Add( new Grant() );

            serviceMember
                .AddCase( new Case( 1L, PersistentModel.NEW_VERSION, new List<Injury>(), serviceMember, volunteer, grants1 ) )
                .AddCase( new Case( 2L, PersistentModel.NEW_VERSION, new List<Injury>(), serviceMember, volunteer, grants2 ) );

            Assert.AreEqual( 5, new List<Grant>( serviceMember.Grants ).Count );
        }
        #endregion

        #region Support Methods
        #endregion

        #region Data Elements
        #endregion

    }
}
